import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useMemberStore = defineStore( 'member', () => {
	
    const profile = ref<LoginResult|null>()    // 账号信息

    const setProfile = (val: LoginResult) =>  profile.value = val    // 设置账号信息，登录时使用

    const clearProfile = () =>   profile.value = null // 清理会员信息，退出时使用

    return {   profile, setProfile, clearProfile }
	
  },
  {
      persist: {
        storage: {
          getItem:(key)=>  uni.getStorageSync(key),
          setItem:(key, value)=> uni.setStorageSync(key, value)
        }
      }
  }
)
